package io.renren.modules.project.controller;

import java.util.Arrays;
import java.util.Map;
import java.util.List;

import io.renren.common.annotation.SysLog;
import io.renren.modules.project.entity.QualityOutputEntity;
import io.renren.modules.project.service.QualityOutputService;
import io.renren.modules.project.vo.GroupRequestVoEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

/**
 * 质检产值表
 *
 * @author ygg
 * @date 2021-08-31 15:24:29
 */
@RestController
@RequestMapping("project/qualityoutput")
public class QualityOutputController {
    @Autowired
    private QualityOutputService qualityOutputService;


    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        List<QualityOutputEntity> list = qualityOutputService.queryList(params);

        return R.ok().put("list", list);
    }


    /**
     * 保存
     */
    @SysLog("保存质检产值")
    @RequestMapping("/saveList")
    public R saveList(@RequestBody GroupRequestVoEntity requestVoEntity){
        qualityOutputService.deleteByProjectNo(requestVoEntity.getProjectNo());
        if (requestVoEntity.getqOutputList().size() > 0) {
            qualityOutputService.insertBatch(requestVoEntity.getqOutputList());
        }
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("project:qualityoutput:delete")
    public R delete(@RequestBody Long[] ids){
		qualityOutputService.deleteBatch(ids);

        return R.ok();
    }

}
